package com.alibaba.citrus.ots.forecast.facade.service;

import com.alibaba.citrus.ots.forecast.repository.CartonSpecsRepository;
import com.alibaba.lattice2.epoch.sdk.model.Result;
import com.epoch.app.otsforecastsales.cartonspecsquery.service.CartonSpecsQueryService;
import com.epoch.app.otsforecastsales.model.dto.CartonSepcsRequest;
import com.epoch.app.otsforecastsales.model.dto.CartonSpecsSDO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Primary
public class CartonSpecsQueryServiceImpl implements CartonSpecsQueryService {
    @Autowired
    private CartonSpecsRepository cartonSpecsRepository;

    @Override
    public Result<CartonSpecsSDO> querySingle(CartonSepcsRequest cartonSepcsRequest){

        List<CartonSpecsSDO> cartonSpecsSDOS = cartonSpecsRepository.queryList(cartonSepcsRequest);
        if (CollectionUtils.isNotEmpty(cartonSpecsSDOS)){
            return Result.success(cartonSpecsSDOS.get(0));
        }
        return null;
    }
}
